<style>
    .pl30 {
        padding-left: 30px;
    }

    .mb20 {
        margin-bottom: 20px;
    }
    
</style>
<style scoped>
</style>

<template>
    <div class="basic_update">
        <product-title></product-title>
        <div class="wrap pl30">
            <Form :label-width="200">
                <Col>
                <FormItem label="保费保单详情 :">
                    <Button type="primary" @click="syncuserinfo0">保费保单详情</Button>
                </FormItem>
                <FormItem label="待转正营销员 :">
                    <Button type="primary" @click="syncuserinfo1">待转正营销员</Button>
                </FormItem>
                <FormItem label="待晋升营销员 :">
                    <Button type="primary" @click="syncuserinfo2">待晋升营销员</Button>
                </FormItem>
                <FormItem label="津贴详情 :">
                    <Button type="primary" @click="syncuserinfo3">津贴详情</Button>
                </FormItem>
                <FormItem label="薪资详情 :">
                    <Button type="primary" @click="syncuserinfo5">薪资详情</Button>
                </FormItem>
                </Col>
            </Form>
        </div>
        <Modal v-model="modal1" id="modal1" title="保费保单详情" :closable="false" :width="1200" :mask-closable="false" class-name="common-box-body">
            <Form >
                <Row>
                    <Col :xs="24" :sm="24" :md="24" :lg="5">
                    <FormItem >
                        <DatePicker type="month" :options="options" v-model="searchForm1.datetime" transfer format="yyyy-MM" placeholder="请选择日期"
                            @on-change="dateChange"></DatePicker>
                    </FormItem>
                    </Col>

                    <Col :md="24" :lg="5">
                    <FormItem>
                        <Input v-model="searchForm1.policy_num" placeholder="请输入保单号"></Input>
                    </FormItem>
                    </Col>

                    <Col :md="24" :lg="5">
                    <FormItem>
                        <Input v-model="searchForm1.name" placeholder="请输入营销员"></Input>
                    </FormItem>
                    </Col>


                    <Col :md="24" :lg="2" offset="2">
                    <Button size="large" type="info" icon="ios-search" @click="search">搜索</Button>
                    </Col>
                    <Col :md="24" :lg="2">
                    <Button size="large" type="primary" :disabled='canclick' @click="addModal1">批量更新</Button>
                    </Col>
                    <Col :md="24" :lg="3">
                    <Button size="large" type="error" @click="clean1">清空当月日志</Button>
                    </Col>
                </Row>
            </Form>
            <div v-if="progress" style="padding:10px">
                <Progress :percent="percent"></Progress>
            </div>
            <div class="">
                <Table size="large" stripe border :columns="columns" :data="tableList" class="">
                </Table>
            </div>
            <div :md="24" :lg="16" class="tRight mod_table mt15">
                <Page ref="pages" :total="listTotal" :page-size="pagesize" @on-change="pageChange" placement="top" class="page"></Page>
            </div>
            <div slot="footer">
                <Col>
                <Button type="default" size="samll" @click="back">取消</Button>
                </Col>
            </div>
        </Modal>
        <Modal v-model="modal2" title="待转正营销员" :closable="false" :width="1200" :mask-closable="false" class-name="common-box-body">

            <div class="">
                <Table size="large" stripe border :columns="columns2" :data="tableList2" class="">
                </Table>
            </div>
            <div :md="24" :lg="16" class="tRight mod_table mt15">
                <Page ref="pages2" :total="listTotal2" :page-size="pagesize2" @on-change="pageChange2" placement="top" class="page"></Page>
            </div>
            <div slot="footer">
                <Col>
                <!-- <Button type="success" size="samll" @click="addModal2">全部转正</Button> -->
                <Button type="default" size="samll" @click="back2">取消</Button>
                </Col>
            </div>
        </Modal>
        <!-- syncuserinfoTwo -->
        <Modal v-model="syncuserinfoTwo" :closable="false" title="待晋升营销员" :width="1200" :mask-closable="false" class-name="common-box-body">

            <div v-if="progressJin" style="padding:10px">
                <Progress :percent="percentJin"></Progress>
            </div>
            <div class="">
                <Table size="large" stripe border :columns="columnsJin" :data="tableListJin" class="">
                </Table>
            </div>
            <div :md="24" :lg="16" class="tRight mod_table mt15">
                <Page ref="pagesJin" :total="listTotalJin" :page-size="pagesizea" @on-change="pageChangea" placement="top" class="page"></Page>
            </div>
            <div slot="footer">
                <Col>
                <Button type="success" size="samll" :disabled='canclick' @click="addModalJin">全部晋升</Button>
                <Button type="default" size="samll" @click="backJin">取消</Button>
                </Col>
            </div>
        </Modal>
        <Modal v-model="modal4" title="津贴详情" :closable="false" :width="1200" :mask-closable="false" class-name="common-box-body">
            <Form >
                <Row>
                    <Col :md="24" :lg="5">
                    <FormItem>
                        <DatePicker type="month" :options="options" v-model="searchForm4.datetime" transfer format="yyyy-MM" placeholder="请选择日期"
                            @on-change="dateChange4"></DatePicker>
                    </FormItem>
                    </Col>

                    <Col :md="24" :lg="4">
                    <FormItem>
                        <Input v-model="searchForm4.policy_num" placeholder="请输入保单号"></Input>
                    </FormItem>
                    </Col>
                    <Col :md="24" :lg="4">
                    <FormItem>
                        <Input v-model="searchForm4.name" placeholder="请输入营销员姓名"></Input>
                    </FormItem>
                    </Col>
                    <Col :md="24" :lg="4">
                    <FormItem>
                        <Select v-model="searchForm4.cate" transfer placeholder='请选择津贴类型'>
                            <Option value="0">全部</Option>
                            <Option value="推荐转正津贴">推荐转正津贴</Option>
                            <Option value="终身推荐津贴">终身推荐津贴</Option>
                            <Option value="辅导津贴">辅导津贴</Option>
                            <Option value="管理津贴">管理津贴</Option>
                        </Select>
                    </FormItem>
                    </Col>

                    <Col :md="24" :lg="2">
                    <Button size="large" type="info" icon="ios-search" @click="search4">搜索</Button>
                    </Col>
                    <Col :md="24" :lg="2">
                    <Button size="large" type="primary" :disabled='canclick' @click="addModal4">批量更新</Button>
                    </Col>
                    <Col :md="24" :lg="3">
                    <Button size="large" type="error" @click="clean4">清空津贴日志</Button>
                    </Col>
                </Row>
            </Form>
            <div v-if="progress4" style="padding:10px">
                <Progress :percent="percent4"></Progress>
            </div>
            <div class="">
                <Table size="large" stripe border :columns="columns4" :data="tableList4" class="">
                </Table>
            </div>
            <div :md="24" :lg="16" class="tRight mod_table mt15">
                <Page ref="pages4" :total="listTotal4" :page-size="pagesize4" @on-change="pageChange4" placement="top" class="page"></Page>
            </div>
            <div slot="footer">
                <Col>
                <Button type="default" size="samll" @click="back4">取消</Button>
                </Col>
            </div>
        </Modal>
        <Modal v-model="modal5" title="薪资详情" :closable="false" :width="1200" :mask-closable="false" class-name="common-box-body">
            <Form >
                <Row>
                    <Col :md="24" :lg="5">
                    <FormItem>
                        <DatePicker type="month" :options="options" v-model="searchForm5.datetime" transfer format="yyyy-MM" placeholder="请选择日期" 
                            @on-change="dateChange5"></DatePicker>
                    </FormItem>
                    </Col>
                    <Col :md="24" :lg="5">
                    <FormItem>
                        <Input v-model="searchForm5.name" placeholder="请输入营销员姓名"></Input>
                    </FormItem>
                    </Col>
                    <Col :md="24" :lg="4">
                    <FormItem>
                        <Input v-model="searchForm5.job_code" placeholder="请输入工号"></Input>
                    </FormItem>
                    </Col>
                    
                    <Col :md="24" :lg="4">
                    <Select v-model="searchForm5.rank_id" transfer placeholder='请选择级别'>
                        <Option value="0">全部</Option>
                        <Option :value="item.id" v-for="item in rankList" :key="item.id">{{item.name}}</Option>
                    </Select>
                    </Col>

                    <Col :md="24" :lg="2" offset="2">
                    <Button size="large" type="info" icon="ios-search" @click="search5">搜索</Button>
                    </Col>
                    <Col :md="24" :lg="2">
                    <Button size="large" type="primary" :disabled='canclick' @click="addModal5">批量更新</Button>
                    </Col>
                </Row>
            </Form>
            <div v-if="progress5" style="padding:10px">
                <Progress :percent="percent5"></Progress>
            </div>
            <div>
                <Table size="large" @on-current-change="tableCurrentChange($event)" stripe highlight-row border :columns="columns5" :data="tableList5"
                  >
                </Table>
            </div>
            <div :md="24" :lg="16" class="tRight mod_table mt15">
                <Page ref="pages5" :total="listTotal5" :page-size="pagesize5" @on-change="pageChange5" placement="top" class="page"></Page>
            </div>
            <div slot="footer">
                <Col>
                <Button type="default" size="samll" @click="back5">取消</Button>
                </Col>
            </div>
        </Modal>

        <Modal v-model="modal6" title="转正时间" :closable="false" :width="400" :mask-closable="false" class-name="common-box-body">
            <Form :model="formdata" ref="formdata" :rules="ruleValipromotion">
                <Row>
                    <Col span="24">
                    <FormItem label="日期" prop="promotion_timeall" required>
                        <DatePicker type="date" v-model="formdata.promotion_timeall" @on-change="dateChange6($event,formdata,'promotion_time')" placeholder="选择交费日期"></DatePicker>
                    </FormItem>
                    </Col>
                </Row>
            </Form>
            <div slot="footer" :md="24" :lg="8">
                <Button style="width:60px;" type="primary" size="small" @click="cancelModal6">取消</Button>
                <Button style="width:60px;" class="tRight" type="success" size="small" long @click="addModal6">确定</Button>
            </div>
        </Modal>
        <Modal v-model="modal7" title="晋升时间" :closable="false" :width="400" :mask-closable="false" class-name="common-box-body">
            <Form :model="syncTwo" ref="syncTwo" :rules="ruleValisyncTwo">
                <Row>
                    <Col span="24">
                    <FormItem label="日期" prop="promotion_timeall" required>
                        <DatePicker type="date" v-model="syncTwo.promotion_timeall" @on-change="dateChange7($event,syncTwo,'promotion_time')" placeholder="选择交费日期"></DatePicker>
                    </FormItem>
                    </Col>
                </Row>
            </Form>
            <div slot="footer" :md="24" :lg="8">
                <Button style="width:60px;" type="primary" size="small" @click="cancelModal7">取消</Button>
                <Button style="width:60px;" class="tRight" type="success" size="small" long @click="addModal7">确定</Button>
            </div>
        </Modal>
    </div>
</template>
<script>
    import productTitle from '../../components/productTitle'
    import {
        formatTime
    } from '../../libs/time'
    import {
        getRankList
    } from '../../api/rank'
    import {
        get_policy_log,
        get_policy_log_count,
        batch_deal_policy_log,
        get_regular_emp2,
        set_regular2,
        set_regular_all2,
        promotion_emp,
        batch_deal_promotion,
        deal_one_promotion,
        get_allowance,
        batch_deal_allowance,
        get_emps_salary,
        batch_deal_salary,
        has_allowance_count,
        remove_log,
        remove_allowance
    } from '../../api/basic'
    import util from '../../libs/util.js';
    export default {
        data() {
            var year = new Date().getFullYear();
            var month = new Date().getMonth() + 1;
            month = month < 10 ? '0' + month : month;
            var date = new Date().getDate();
            date = date < 10 ? '0' + date : date;
            var get_date = year + '-' + month + '-' + date;
            return {
                rankList: [],
                modal7: false,
                modal6: false,
                ruleValisyncTwo: {
                    promotion_timeall: [{
                        required: true,
                        message: "不能为空",
                        trigger: "blur"
                    }],
                },
                ruleValipromotion: {
                    promotion_timeall: [{
                        required: true,
                        message: "不能为空",
                        trigger: "blur"
                    }],
                },
                options: {
                    disabledDate(date) {
                        let _date = formatTime(new Date(), 'yyyy-MM')
                        return date && date.valueOf() >= (new Date(_date).getTime())
                    }
                },
                progress: false,
                percent: 0,
                canclick: false,
                modal1: false,
                closeable: false, //shif按ese按钮退出
                searchForm1: {
                    p: 1,
                    pagesize: 10,
                    month: '',
                    // month:year+'-'+month,
                    datetime: new Date(formatTime(new Date(), 'yyyy-MM')).getTime(),
                    policy_num: '',
                    name: '',
                },
                page: 1,
                pagesize: 10,
                listTotal: 0,
                count: 0,
                tableList: [],
                columns: [{
                        title: '保单号',
                        key: 'policy_num',
                        align: 'center',
                    },
                    {
                        title: '险种',
                        key: 'pro_name',
                        align: 'center',
                    },
                    {
                        title: '营销员',
                        key: 'emp_name',
                        align: 'center',
                    },
                    {
                        title: '交费期间',
                        key: 'pay_period',
                        align: 'center',
                    },
                    {
                        title: '保费',
                        key: 'premium',
                        align: 'center',
                    },
                    {
                        title: '佣金比例%',
                        key: 'fee',
                        align: 'center',
                    },
                    {
                        title: '佣金FYC',
                        key: 'fyc',
                        align: 'center',
                    },
                    {
                        title: '是否基本法',
                        key: 'has_allowance',
                        align: 'center',
                    },
                    {
                        title: '更新时间',
                        key: 'update_time',
                        align: 'center',
                    },
                ],

                // 转正员工
                modal2: false,
                formdata: {
                    p: 1,
                    pagesize: 10,
                    name: '',
                    promotion_time: get_date,
                    promotion_timeall: get_date,
                },
                page2: 1,
                pagesize2: 10,
                listTotal2: 0,
                tableList2: [],
                progress2: false,
                percent2: 0,
                columns2: [{
                        title: '工号',
                        key: 'job_code',
                        align: 'center',
                    },
                    {
                        title: '姓名',
                        key: 'name',
                        align: 'center',
                    },
                    {
                        title: '佣金',
                        key: 'money',
                        align: 'center',
                    },
                    {
                        title: '入职时间',
                        key: 'join_time',
                        align: 'center',
                    },
                    {
                        title: '是否可转正',
                        key: 'is_regular',
                        align: 'center',
                        render: (h, params) => {
                            return h('div', {},
                                params.row.is_regular == '1' ? '是' : '否')
                        },
                    },
                    {
                        title: '操作',
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                (params.row.is_regular == '1') ? (h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'large'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.revocation(params.row.id)
                                        }
                                    }
                                }, '转正')) : '',


                            ]);
                        }
                    },

                ],

                // 营销员晋升
                syncuserinfoTwo: false,
                syncTwo: {
                    name: '',
                    p: 1,
                    pagesize: 10,
                    eid: '',
                    promotion_timeall: get_date,
                    promotion_time: get_date,
                },
                pageJin: 1,
                syncTwoCount: 0,
                percentJin: 0,
                progressJin: false,
                listTotalJin: 0,
                pagesizea: 10,
                columnsJin: [{
                        title: '工号',
                        key: 'job_code',
                        align: 'center',
                    },
                    {
                        title: '姓名',
                        key: 'name',
                        align: 'center',
                    },
                    {
                        title: '职级',
                        key: 'rank_name',
                        align: 'center',
                    },
                    {
                        title: '推荐人',
                        key: 'rec_name',
                        align: 'center',
                    },
                    {
                        title: '关系上属',
                        key: 'leader_name',
                        align: 'center',
                    },
                    {
                        title: '待晋升状态',
                        key: 'state',
                        align: 'center',
                    },
                    {
                        title: '上次晋升时间',
                        key: 'promotion_time',
                        align: 'center',
                    },
                    {
                        title: '入职时间',
                        key: 'join_time',
                        align: 'center',
                    },
                    {
                        title: '操作',
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                (params.row.state == '确定可晋升') ? (h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'large'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.revocationJin(params.row.id)
                                        }
                                    }
                                }, '晋升')) : '',


                            ]);
                        }
                    },
                ],
                tableListJin: [],


                // 津贴更新
                modal4: false,
                searchForm4: {
                    p: 1,
                    pagesize: 10,
                    month: '',
                    datetime: new Date(formatTime(new Date(), 'yyyy-MM')).getTime(),
                    policy_num: '',
                    name: '',
                    cate: '',
                },
                progress4: false,
                percent4: 0,
                page4: 1,
                pagesize4: 10,
                listTotal4: 0,
                count4: 0,
                tableList4: [],
                columns4: [{
                        title: '保单号',
                        key: 'policy_num',
                        align: 'center',
                    },
                    {
                        title: '险种',
                        key: 'pro_name',
                        align: 'center',
                    },
                    {
                        title: '营销员',
                        key: 'emp_name',
                        align: 'center',
                    },
                    {
                        title: '津贴类型',
                        key: 'cate',
                        align: 'center',
                    },
                    {
                        title: '钱数',
                        key: 'money',
                        align: 'center',
                    },
                    {
                        title: '备注',
                        key: 'remark',
                        align: 'center',
                    },
                    {
                        title: '更新时间',
                        key: 'update_timez',
                        align: 'center',
                    },
                ],

                // 详情薪资
                modal5: false,
                searchForm5: {
                    p: 1,
                    pagesize: 10,
                    month: '',
                    datetime: new Date(formatTime(new Date(), 'yyyy-MM')).getTime(),
                    job_code: '',
                    name: '',
                    rank_id: '',
                },
                progress5: false,
                percent5: 0,
                page5: 1,
                pagesize5: 10,
                listTotal5: 0,
                count5: 0,
                tableList5: [],
                name5: '',
                columns5: [{
                        title: '工号',
                        key: 'job_code',
                        align: 'center',
                    },
                    {
                        title: '姓名',
                        key: 'name',
                        align: 'center',
                    },
                    {
                        title: '职级',
                        key: 'rank_name',
                        align: 'center',
                    },
                    {
                        title: 'FYC',
                        key: 'fyc',
                        align: 'center',
                    },
                    {
                        title: '责任津贴',
                        key: 'duty_allowance',
                        align: 'center',
                    },
                    {
                        title: '推荐转让津贴',
                        key: 'regular_allowance',
                        align: 'center',
                    },
                    {
                        title: '终身推荐津贴',
                        key: 'lifelong_allowance',
                        align: 'center',
                    },
                    {
                        title: '辅导津贴',
                        key: 'coach_allowance',
                        align: 'center',
                    },
                    {
                        title: '大营业部',
                        key: 'big_fyc',
                        align: 'center',
                    },
                    {
                        title: '小营业部',
                        key: 'small_fyc',
                        align: 'center',
                    },
                    {
                        title: '管理津贴',
                        key: 'manage_allowance',
                        align: 'center',
                    },
                    {
                        title: '操作',
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                (params.row.coach_allowance != '0') ? (h('Button', {
                                    // attrs:{
                                    //     target:"_Blank",
                                    //     href:'https://biz.kuaibao365.com/#/basiclaw/basic_salaydetail/'+params.row.id+'/'+params.row.name+'/'+this.searchForm5.month
                                    // },
                                    props: {
                                        type: 'primary',
                                        size: 'large'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.$router.push({
                                                name: 'basic_salaydetail',
                                                params: {
                                                    id: params.row.id,
                                                    name: params.row.name,
                                                    month: this.searchForm5.month
                                                }
                                            });
                                        }
                                    }
                                }, '查看津贴详情')) : '',


                            ]);
                        }
                    },
                ],
            }
        },
        computed: {

        },
        components: {
            productTitle,
        },
        mounted() {

        },
        created() {

            let _time = new Date(formatTime(new Date(), 'yyyy-MM'));
            let _date = formatTime(new Date(_time), 'yyyy-MM');
            this.searchForm1.month = _date;
            this.searchForm4.month = _date;
            this.searchForm5.month = _date;

            this.getRank()
        },
        methods: {
            //获取职级列表
            getRank() {
                new Promise((resolve, reject) => {
                    getRankList().then(response => {
                        if (response.data.err == 0) {
                            this.rankList = response.data.data;
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
            datachange1(date, obj, attr) {
                obj[attr] = date;
            },
            // 点击保费,弹出弹框,  初始化获取保费列表
            getBao() {
                new Promise((resolve, reject) => {
                    get_policy_log(this.searchForm1).then(response => {
                        if (response.data.err == 0) {
                            this.tableList = response.data.data.list;
                            this.listTotal = response.data.data.total;
                            console.log(this.listTotal, '...', this.tableList)
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
            getNum() {
                new Promise((resolve, reject) => {
                    get_policy_log_count(this.searchForm1).then(response => {
                        if (response.data.err == 0) {
                            this.count = Math.ceil(response.data.data.count / 20)
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
            syncuserinfo0() {
                this.modal1 = true;
                this.getBao();
                this.getNum();
            },
            // 保单详情的搜索
            search() {
                this.getBao();
                this.getNum();
                this.$refs['pages'].currentPage = 1;
            },
            // 页码改变
            pageChange(page) {
                this.searchForm1.p = page;
                this.getBao()
            },
            addModal1() {
                this.percent = 0;
                this.$refs['pages'].currentPage = 1;
                this.searchForm1.p = 1;
                this.searchForm1.pagesize = 20;

                let _userlistasc = this.count;
                if (_userlistasc > 0) {
                    this.progress = true;
                    this.sync(_userlistasc)
                } else {
                    this.$Message.error('没有查询到保单相关信息');
                }
            },
            sync(_userlistasc) {
                if (this.searchForm1.p > _userlistasc) {
                    this.searchForm1.p = 1;
                    this.searchForm1.pagesize = 10;
                    this.getBao();
                    this.canclick = false

                    return;
                }
                new Promise((resolve, reject) => {
                    batch_deal_policy_log(this.searchForm1).then(response => {
                        this.percent = parseInt((this.searchForm1.p * 100 / _userlistasc).toFixed(1))
                        this.searchForm1.p++
                            this.canclick = true;
                        setTimeout(() => {
                            this.sync(_userlistasc)
                        }, 800);
                        resolve();
                    }).catch(error => {
                        this.canclick = false
                        reject(error);
                    });
                });
            },
            // 清楚保费日志
            clean1() {
                var data = {
                    month: this.searchForm1.month
                }
                new Promise((resolve, reject) => {
                    remove_log(data).then(response => {
                        if (response.data.err == 0) {
                            this.$Message.success(response.data.info)
                            this.getBao();
                            this.getNum();
                        } else {
                            this.$Message.error(response.data.info)
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
            //时间转换
            dateChange(date) {
                if (date) {
                    console.log(date)
                    this.searchForm1.month = date
                } else {
                    this.searchForm1.month = ''
                }

            },
            back() {
                let _time = new Date(formatTime(new Date(), 'yyyy-MM'));
                let _date = formatTime(new Date(_time), 'yyyy-MM');
                this.searchForm1.month = _date;
                this.searchForm1.datetime = _date;
                this.progress = false;
                this.percent = 0;
                this.modal1 = false;
                this.searchForm1.p = 1;
                this.searchForm1.pagesize = 10;
            },




            // 点击员工转正,弹出弹框,  初始化获取列表
            getBao1() {
                new Promise((resolve, reject) => {
                    get_regular_emp2(this.formdata).then(response => {
                        if (response.data.err == 0) {
                            this.tableList2 = response.data.data.list;
                            this.listTotal2 = response.data.data.total;
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
            syncuserinfo1() {
                this.modal2 = true;
                this.getBao1();
            },
            pageChange2(page) {
                this.formdata.p = page;
                this.getBao1()
            },
            search1() {
                var data = {
                    name: this.formdata.name
                }
                new Promise((resolve, reject) => {
                    get_regular_emp2(data).then(response => {
                        if (response.data.err == 0) {
                            this.tableList2 = response.data.data.list;
                            this.listTotal2 = response.data.data.total;
                            this.$refs['pages2'].currentPage = 1;
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });

            },
            revocation(id) {
                this.modal2 = false;
                this.modal6 = true;
                this.formdata.id = id
            },
            addModal2() {
                this.modal2 = false;
                this.modal6 = true;
            },
            cancelModal6() {
                this.modal2 = true;
                this.modal6 = false;
            },
            addModal6() {
                if (this.formdata.id) {
                    this.formdata.eid = this.formdata.id;
                    new Promise((resolve, reject) => {
                        set_regular2(this.formdata).then(response => {
                            console.log(response.data)
                            if (response.data.err == 0) {
                                this.$Message.success(response.data.info);
                                this.formdata.id = '';
                                this.formdata.eid = '';
                                var year = new Date().getFullYear();
                                var month = new Date().getMonth() + 1;
                                month = month < 10 ? '0' + month : month;
                                var date = new Date().getDate();
                                date = date < 10 ? '0' + date : date;
                                var get_date = year + '-' + month + '-' + date;
                                this.formdata.promotion_time = get_date;
                                this.formdata.promotion_timeall = get_date;
                                this.getBao1();
                                this.$refs['pages2'].currentPage = 1;
                                this.formdata.p = 1;
                                this.modal2 = true;
                                this.modal6 = false;
                            } else {
                                this.$Message.error(response.data.info);
                            }
                            resolve();
                        }).catch(error => {
                            reject(error);
                        });
                    });
                } else {
                    new Promise((resolve, reject) => {
                        set_regular_all2(this.formdata).then(response => {
                            if (response.data.err == 0) {
                                this.$Message.success('员工批量更新成功!');
                                this.getBao1();
                                var year = new Date().getFullYear();
                                var month = new Date().getMonth() + 1;
                                month = month < 10 ? '0' + month : month;
                                var date = new Date().getDate();
                                date = date < 10 ? '0' + date : date;
                                var get_date = year + '-' + month + '-' + date;
                                this.formdata.promotion_time = get_date;
                                this.formdata.promotion_timeall = get_date;
                                this.$refs['pages2'].currentPage = 1;
                                this.formdata.p = 1;
                                this.formdata.id = '';
                                this.formdata.eid = '';
                                this.modal2 = true;
                                this.modal6 = false;
                            } else {
                                this.$Message.error(response.data.info);
                            }
                            resolve();
                        }).catch(error => {
                            reject(error);
                        });
                    });
                }

            },
            back2() {
                this.formdata.name = "";
                this.$refs['pages2'].currentPage = 1;
                this.modal2 = false;
            },



            // 点击带晋升营销员
            getJin() {
                new Promise((resolve, reject) => {
                    promotion_emp(this.syncTwo).then(response => {
                        if (response.data.err == 0) {
                            this.tableListJin = response.data.data.list;
                            this.listTotalJin = response.data.data.total;
                            this.syncTwoCount = response.data.data.total;
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
            syncuserinfo2() {
                this.syncuserinfoTwo = true;
                this.getJin();
            },
            pageChangea(page) {
                this.syncTwo.p = page;
                this.getJin()
            },
            searchJin() {
                new Promise((resolve, reject) => {
                    get_regular_emp2(this.syncTwo).then(response => {
                        if (response.data.err == 0) {
                            this.tableListJin = response.data.data.list;
                            this.listTotalJin = response.data.data.total;
                            this.$refs['pagesJin'].currentPage = 1;
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });

            },
            // 全部晋升
            addModalJin() {
                this.syncuserinfoTwo = false;
                this.modal7 = true;
            },
            syncJin(_userlistasc) {
                if (this.syncTwo.p > _userlistasc) {
                    this.syncTwo.p = 1;
                    this.syncTwo.pagesize = 10;
                    this.getJin();
                    var year = new Date().getFullYear();
                    var month = new Date().getMonth() + 1;
                    month = month < 10 ? '0' + month : month;
                    var date = new Date().getDate();
                    date = date < 10 ? '0' + date : date;
                    var get_date = year + '-' + month + '-' + date;
                    this.syncTwo.promotion_time = get_date;
                    this.syncTwo.promotion_timeall = get_date;
                    this.canclick = false

                    return;
                }
                new Promise((resolve, reject) => {
                    batch_deal_promotion(this.syncTwo).then(response => {
                        this.percentJin = parseInt((this.syncTwo.p * 100 / _userlistasc).toFixed(1))
                        this.syncTwo.p++
                            this.canclick = true;
                        setTimeout(() => {
                            this.syncJin(_userlistasc)
                        }, 800);
                        resolve();
                    }).catch(error => {
                        this.canclick = false
                        reject(error);
                    });
                });
            },
            revocationJin(id) {
                this.syncuserinfoTwo = false;
                this.modal7 = true;
                this.syncTwo.eid = id;
            },
            backJin() {
                this.syncuserinfoTwo = false;
                this.progressJin = false;
                this.$refs['pagesJin'].currentPage = 1;
            },
            cancelModal7() {
                this.syncuserinfoTwo = true;
                this.modal7 = false;
            },
            addModal7() {
                if (this.syncTwo.eid && (this.syncTwo.eid != '')) {
                    new Promise((resolve, reject) => {
                        deal_one_promotion(this.syncTwo).then(response => {
                            console.log(response.data)
                            if (response.data.err == 0) {
                                this.syncuserinfoTwo = true;
                                this.modal7 = false;
                                this.syncTwo.eid = '';
                                var year = new Date().getFullYear();
                                var month = new Date().getMonth() + 1;
                                month = month < 10 ? '0' + month : month;
                                var date = new Date().getDate();
                                date = date < 10 ? '0' + date : date;
                                var get_date = year + '-' + month + '-' + date;
                                this.syncTwo.promotion_time = get_date;
                                this.syncTwo.promotion_timeall = get_date;
                                this.getJin();
                                this.$refs['pagesJin'].currentPage = 1;
                                this.syncTwo.p = 1;
                            } else {
                                this.$Message.error(response.data.info);
                            }
                            resolve();
                        }).catch(error => {
                            reject(error);
                        });
                    });
                } else {
                    this.syncuserinfoTwo = true;
                    this.modal7 = false;
                    this.syncTwo.eid = '';

                    this.percentJin = 0;
                    this.$refs['pagesJin'].currentPage = 1;
                    this.syncTwo.p = 1;
                    this.syncTwo.pagesize = 10;
                    let _userlistasc = this.syncTwoCount;
                    if (_userlistasc > 0) {
                        this.progressJin = true;
                        this.syncJin(_userlistasc)
                    } else {
                        this.$Message.error('没有查询到相关人员的晋升信息');
                    }
                }
            },

            // 获取津贴更新的详情
            syncuserinfo3() {
                this.modal4 = true;
                this.getBao4();
                this.getNum4();
            },
            search4() {
                this.getBao4();
                this.getNum4();
                this.$refs['pages4'].currentPage = 1;
            },
            getNum4() {
                var data = {
                    month: this.searchForm4.month
                }
                new Promise((resolve, reject) => {
                    has_allowance_count(data).then(response => {
                        if (response.data.err == 0) {
                            this.count4 = Math.ceil(response.data.data.count / 10)
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
            back4() {
                let _time = new Date(formatTime(new Date(), 'yyyy-MM'));
                let _date = formatTime(new Date(_time), 'yyyy-MM');
                this.searchForm4.month = _date;
                this.searchForm4.datetime = _date;
                this.$refs['pages4'].currentPage = 1;
                this.searchForm4.p = 1;
                this.searchForm4.pagesize4 = 10;
                this.progress4 = false;
                this.modal4 = false;
            },
            // 页码改变
            pageChange4(page) {
                this.searchForm4.p = page;
                this.getBao4()
            },
            //时间转换
            dateChange4(date) {
                if (date) {
                    console.log(date)
                    this.searchForm4.month = date
                } else {
                    this.searchForm4.month = ''
                }

            },
            getBao4() {
                new Promise((resolve, reject) => {
                    get_allowance(this.searchForm4).then(response => {
                        if (response.data.err == 0) {
                            this.tableList4 = response.data.data.list;
                            this.listTotal4 = response.data.data.total;
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
            clean4() {
                var data = {
                    month: this.searchForm4.month
                }
                new Promise((resolve, reject) => {
                    remove_allowance(data).then(response => {
                        if (response.data.err == 0) {
                            this.$Message.success(response.data.info)
                            this.getBao4()
                        } else {
                            this.$Message.error(response.data.info)
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
            addModal4() {
                this.percent4 = 0;
                this.$refs['pages4'].currentPage = 1;
                this.searchForm4.p = 1;
                this.searchForm4.pagesize = 10;

                let _userlistasc = this.count4;
                if (_userlistasc > 0) {
                    this.progress4 = true;
                    this.sync4(_userlistasc)
                } else {
                    this.$Message.error('没有查询到津贴相关信息');
                }
            },
            sync4(_userlistasc) {
                if (this.searchForm4.p > _userlistasc) {
                    this.searchForm4.p = 1;
                    this.searchForm4.pagesize = 10;
                    this.getBao4();
                    this.canclick = false;
                    return;
                }
                new Promise((resolve, reject) => {
                    batch_deal_allowance(this.searchForm4).then(response => {
                        this.percent4 = parseInt((this.searchForm4.p * 100 / _userlistasc).toFixed(1))
                        this.searchForm4.p++
                            this.canclick = true;
                        setTimeout(() => {
                            this.sync4(_userlistasc)
                        }, 800);
                        resolve();
                    }).catch(error => {
                        this.canclick = false
                        reject(error);
                    });
                });
            },

            // 薪资详情
            syncuserinfo5() {
                this.modal5 = true;
                this.getBao5()
            },
            search5() {
                this.searchForm5.p = 1;
                this.getBao5();
                this.$refs['pages5'].currentPage = 1;
            },
            back5() {
                let _time = new Date(formatTime(new Date(), 'yyyy-MM'));
                let _date = formatTime(new Date(_time), 'yyyy-MM');
                this.searchForm5.month = _date;
                this.searchForm5.datetime = _date;
                this.$refs['pages5'].currentPage = 1;
                this.progress5 = false;
                this.percent5 = 0;
                this.modal5 = false;
            },
            // 页码改变
            pageChange5(page) {
                this.searchForm5.p = page;
                this.getBao5()
            },
            //时间转换
            dateChange5(date) {
                if (date) {
                    console.log(date)
                    this.searchForm5.month = date
                } else {
                    this.searchForm5.month = ''
                }
            },
            getBao5() {
                new Promise((resolve, reject) => {
                    get_emps_salary(this.searchForm5).then(response => {
                        if (response.data.err == 0) {
                            this.tableList5 = response.data.data.list;
                            this.listTotal5 = response.data.data.total;
                            this.count5 = Math.ceil(response.data.data.total / 1)
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
            addModal5() {
                this.percent5 = 0;
                this.$refs['pages5'].currentPage = 1;
                this.searchForm5.p = 1;
                this.searchForm5.pagesize = 1;

                let _userlistasc = this.count5;
                if (_userlistasc > 0) {
                    this.progress5 = true;
                    this.sync5(_userlistasc)
                } else {
                    this.$Message.error('没有查询到津贴相关信息');
                }
            },
            sync5(_userlistasc) {
                if (this.searchForm5.p > _userlistasc) {
                    this.searchForm5.p = 1;
                    this.searchForm5.pagesize = 10;
                    this.getBao5();
                    this.canclick = false;
                    return;
                }
                new Promise((resolve, reject) => {
                    batch_deal_salary(this.searchForm5).then(response => {
                        this.percent5 = parseInt((this.searchForm5.p * 100 / _userlistasc).toFixed(1))
                        this.searchForm5.p++
                            this.canclick = true;
                        setTimeout(() => {
                            this.sync5(_userlistasc)
                        }, 800);
                        resolve();
                    }).catch(error => {
                        this.canclick = false
                        reject(error);
                    });
                });
            },
            //选中当前行数据
            tableCurrentChange(currentRow, oldCurrentRow) {
                this.current = currentRow;
            },
            detail5(id) {
                // console.log(id,this.name5,this.tableList5);
                for (var i in this.tableList5) {
                    if (this.tableList5[i].id == id) {
                        this.name5 = this.tableList5[i].name
                    }
                }
                console.log(this.name5)
                this.$router.push({
                    'name': 'basic_salaydetail',
                    params: {
                        id: id,
                        name: this.name5,
                        month: this.searchForm5.month
                    }
                })
            },
            //时间转换
            dateChange6(date) {
                if (date) {
                    console.log(date)
                    this.formdata.promotion_time = date
                } else {
                    this.formdata.promotion_time = ''
                }
            },
            dateChange7(date) {
                if (date) {
                    console.log(date)
                    this.syncTwo.promotion_time = date
                } else {
                    this.syncTwo.promotion_time = ''
                }
            },
        }
    }
</script>